import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class resource_leak {
  // Classic Two Resources Bug
  public static my_output foo() throws IOException {
    my_input in = null;
    my_output out = null;
    try {
      in = new my_input(new FileInputStream(new File("whatever.txt")));
      out = new my_output(new FileOutputStream(new File("everwhat.txt")));
      out.write(in.read());
    } finally {
      // Here, if there is an exception in the call to `fis.close()` execution
      // will skip past `fos.close();` a leak.
      if (in != null)
        in.close();
      if (out != null)
        out.close();
    }

    return out;
  }
}
